package o;

import android.app.Service;
import android.content.Context;
import android.os.Binder;
import android.os.Bundle;
import android.os.RemoteException;
import com.huawei.gamebox.wallet.view.WalletStartActivity;
import com.huawei.gamebox.wallet.view.WalletStartLandscapeActivity;
import com.huawei.hms.support.api.entity.pay.HwPayConstant;
import com.huawei.hms.support.api.entity.pay.PayStatusCodes;
import java.util.HashMap;
import java.util.Map;
import o.awd.d;

public class avz extends d {
    private static final HashMap<String, Object> ˊ = new HashMap();
    private static final HashMap<String, Object> ˋ = new HashMap();
    private static final HashMap<String, String> ˏ = new HashMap();
    private static final HashMap<String, Map> ॱ = new HashMap();
    private Context ˎ;
    private long ᐝ = 0;

    public avz(Service service) {
        this.ˎ = service;
    }

    public static void ˏ(String str) {
        Object obj = ˋ.get(str);
        if (obj != null) {
            synchronized (obj) {
                if (ˊ.get(str) != null) {
                    try {
                        obj.notifyAll();
                    } catch (Throwable e) {
                        Logger.ˋ("HuaweiPayServiceImpl", "finishedPayAction notifyAll exception", e);
                    }
                }
            }
        }
    }

    public static Map ॱ(String str) {
        Object obj = ॱ.get(str);
        if (obj != null) {
            return (Map) obj;
        }
        Logger.e("HuaweiPayServiceImpl", "getOrderInfo is null, " + str);
        return new HashMap();
    }

    public static Object ˋ(String str) {
        return ˏ.get(str);
    }

    public static Object ˎ(String str) {
        return ˊ.get(str);
    }

    public static void ˎ(String str, Object obj) {
        ˊ.put(str, obj);
    }

    public String ˏ(Map map, awf o_awf) throws RemoteException {
        if (map == null || o_awf == null) {
            Logger.ˏ("HuaweiPayServiceImpl", " paraMap is null) ");
            return "{\"" + "returnCode" + "\":\"" + PayStatusCodes.PAY_STATE_ERROR + "\"}";
        }
        String valueOf = String.valueOf(Binder.getCallingPid());
        Object obj = map.get(HwPayConstant.KEY_REQUESTID);
        if (obj instanceof String) {
            String str = valueOf + "_" + obj;
            synchronized (ˋ) {
                if (!ˋ.containsKey(str)) {
                    ˏ(System.currentTimeMillis());
                    ॱ.put(str, map);
                    String[] packagesForUid = this.ˎ.getPackageManager().getPackagesForUid(Binder.getCallingUid());
                    if (packagesForUid != null) {
                        valueOf = packagesForUid[0];
                        ˏ.put(str, valueOf);
                        if (Logger.ˎ()) {
                            Logger.ˏ("HuaweiPayServiceImpl", "calling package name = " + valueOf);
                        }
                    }
                    int i = 1;
                    if (map.containsKey("screentOrient")) {
                        i = ((Integer) map.get("screentOrient")).intValue();
                    }
                    Bundle bundle = new Bundle();
                    bundle.putString("CallingPid", str);
                    bundle.putString("pay", "YES");
                    String packageName = this.ˎ.getPackageName();
                    if (2 == i) {
                        valueOf = WalletStartLandscapeActivity.class.getName();
                    } else {
                        valueOf = WalletStartActivity.class.getName();
                    }
                    o_awf.ˋ(packageName, valueOf, Binder.getCallingPid(), bundle);
                    ˋ.put(str, new Object());
                    ˊ.put(str, null);
                }
            }
            synchronized (ˋ.get(str)) {
                while (ˊ.get(str) == null) {
                    try {
                        ˋ.get(str).wait();
                    } catch (Throwable e) {
                        Logger.ˋ("HuaweiPayServiceImpl", "Exception ", e);
                    }
                }
                valueOf = (String) ˊ.get(str);
                ˋ.remove(str);
                ॱ.remove(str);
                ˊ.remove(str);
                ˏ.remove(str);
            }
            return valueOf;
        }
        Logger.ˏ("HuaweiPayServiceImpl", " requestId is null) ");
        return "{\"" + "returnCode" + "\":\"" + PayStatusCodes.PAY_STATE_ERROR + "\"}";
    }

    public void ॱ() throws RemoteException {
        if (System.currentTimeMillis() > ˏ() + 3000) {
            String num = Integer.toString(Binder.getCallingPid());
            Object obj = ˋ.get(num);
            if (obj != null) {
                synchronized (obj) {
                    if (ˊ.get(num) == null) {
                        try {
                            obj.notifyAll();
                        } catch (Throwable e) {
                            Logger.ˋ("HuaweiPayServiceImpl", "finishedPayAction notifyAll exception", e);
                        }
                    }
                }
            }
        }
    }

    public String ॱ(int i, Map map, awf o_awf) throws RemoteException {
        return null;
    }

    public void ˋ() throws RemoteException {
    }

    private long ˏ() {
        return this.ᐝ;
    }

    private void ˏ(long j) {
        this.ᐝ = j;
    }
}
